import { defineConfig,loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  base:'./',
  build:{
    outDir: 'dist',
    terserOptions: {
      compress: {
        drop_console: true, // 删除打包时的console
      }
    }
  },
  server:{
    host: 'localhost',
    port: 8080,
    open: true,
    hmr: true,
    proxy:{
      '/api':{
        target:'http://eduboss.lagounews.com/',
        changeOrigin: true,
        rewrite: path =>path.replace(/\api/,'')
      }
    }
  },
  resolve:{
    alias:{
      '@': resolve(__dirname, './src')
    },
    extensions:['.ts','.vue','.json','.jsx', 'js', '.tsx', 'mjs', 'mts']
  },
  css:{
    preprocessorOptions:{
      less:{
        charset: false,
        additionalData: '@import "@/styles/global.less";'
      }
    }
  }
})
